<html>
<head>
<title>jboot websocket test</title>
<script>
    var socket;
    if (window.WebSocket) {
        socket = new WebSocket("ws://localhost:8080/ws/test");
        socket.onmessage = function (event) {
            var chat = document.getElementById('chat');
            chat.innerHTML = chat.innerHTML + event.data + "<br />";
        };
    } else {
        alert("Your browser does not support Websockets. (Use Chrome)");
    }

    function send(message) {
        if (!window.WebSocket) {
            return false;
        }
        if (socket.readyState == WebSocket.OPEN) {
            socket.send(message);
        } else {
            alert("The socket is not open.");
        }
        return false;
    }
</script>
</head>
<body>
<div>
    <div>
        <h1>jboot websocket test</h1>
        <form onsubmit="return false;" action="">
            <label for="msg">Message:</label>
            <input type="text" name="message" id="msg"  onkeypress="if(event.keyCode==13) { send(this.form.message.value); this.value='' } " />
        </form>
        <label id="chat" style="height:100%;width: 100%;"></label>
    </div>
</div>
</body>
</html>